package com.yami.shop.bean.enums;

import com.yami.shop.common.i18n.I18nMessage;
import com.yami.shop.common.i18n.LanguageEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * excel错误信息参数
 * @author gaozijie
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ExcelErrorParam {
    /**
     * 行号
     */
    private Integer rowNum;
    /**
     * 错误类型
     */
    private Integer errorType;
    /**
     * 错误参数
     */
    private String data;
    /**
     * 错误原因
     */
    private String errorReason;
    /**
     * 错误信息
     */
    private String errorMsg;

    public ExcelErrorParam(Integer rowNum, Integer errorType, String data, String errorReason) {
        this.rowNum = rowNum;
        this.errorType = errorType;
        this.data = data;
        this.errorReason = errorReason;
    }

    public String getErrorMsg() {
        boolean isCN = Objects.equals(I18nMessage.getLang(), LanguageEnum.LANGUAGE_ZH_CN.getLang());
        errorMsg = isCN ?
                "第" + rowNum + "行" + this.errorReason :
                "Line " + rowNum + " " + this.errorReason;
        return errorMsg;
    }
}
